﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;

namespace WooCoo.DataPortal.Client
{
    public static class ODataVersionTools
    {
        /// <summary>
        /// Empty OData Version - represents a blank OData-Version header
        /// </summary>
        public static readonly Version ODataVersionEmpty = new Version(0, 0);
        /// <summary>
        /// OData Version 4
        /// </summary>
        public static readonly Version ODataVersion4 = new Version(4, 0);

        /// <summary>
        /// 目前系统只支持V4的反序列化
        /// </summary>
        internal static readonly Version[] SupportedResponseVersions = 
        { 
            ODataVersion4,
        };

        /// <summary>
        /// 根据传入的OData协议版本，转换相应的处理版本信息，但目前只支持4.0版本
        /// Converts the ODataProtocolVersion to a Version instance.
        /// </summary>
        /// <param name="maxProtocolVersion">The max protocol version value.</param>
        /// <returns>The same version expressed as Version instance.</returns>
        internal static Version GetVersionFromMaxProtocolVersion(ODataProtocolVersion maxProtocolVersion)
        {
            switch (maxProtocolVersion)
            {
                case ODataProtocolVersion.V4:
                    return ODataVersionTools.ODataVersion4;
                default:
                    Debug.Assert(false, "Unexpected max protocol version values.");
                    return ODataVersionTools.ODataVersion4;
            }
        }
    }
}
